function Control-NetworkConnection
(
	$names = $(throw "'names' Specify the network names."),
	$disable = $false
)
{
	$ErrorActionPreference  = "Continue"
	
	foreach ($name in $names)
	{
		$networkAdapter = Get-NetworkConnections | where { $_.NetConnectionID -like $name}
		
		if ($networkAdapter -eq $null)
		{
			write-error "No network connection matching the pattern '$name' was found."
		}
		
		$netConnectionId = $networkAdapter.NetConnectionId
		
		if ($disable -eq $false)
		{
			write-host "Enabling network adapter $netConnectionId"  -foregroundcolor yellow
			$networkAdapter.Enable();
		}
		else
		{
			write-host "Disabling network adapter $netConnectionId"  -foregroundcolor yellow
			$networkAdapter.Disable();
		}
	}
}

function Get-NetworkConnections
{
	gwmi win32_NetworkAdapter | where {$_.NetConnectionId -ne $null}
}